<template>
	<!-- 编辑资料 修改图片 -->
	<view>
		<uni-card>
			<view style="display: flex; justify-content: space-between;" @click="changePic">
				<view>
					<text>头像</text>
				</view>
				<view>
					<image :src="userInfo.avatarUrl" style="width: 80upx;height: 80upx;border-radius: 50%;border: #000000 1upx solid;"></image>
				</view>
			</view>
		</uni-card>
	</view>
</template>

<script>
	export default {
		
		
		data() {
			return {
				userInfo:{},
				imagePath:{}
			}
		},
		created() {
			this.userInfo = JSON.parse(uni.getStorageSync("userInfo"))
			
			
		},
		methods: {
			changePic(){
				 uni.chooseImage({
				   
				    sizeType: ['original'], //可以指定是原图还是压缩图，默认二者都有
				    sourceType: ['album'], //从相册选择
				    success: function (res) {
						this.imagePath=res.tempFiles
						this.openimage()
				    }
				})
				
			},
			async openimage(){
				const res = await this.$request({
					url:'/avatar/upload',
					headers: {
					            'Content-Type': 'multipart/form-data',
					          },
							  data:(this.imagePath.name,this.imagePath.path)
				})
				console.log(res)
			}
			
		}
	}
</script>

<style>

</style>
